<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <div id="app">
      <cpn></cpn>
      <cpn></cpn>
      <cpn></cpn>
    </div>

    <!-- template标签 -->
    <template id="cpn">
      <div>
        <h2>{{title}}</h2>
        <p>我是内容2</p>
      </div>
    </template>

    <script src="../js/vue.js"></script>
    <script>
      // 组件是无法访问到Vue实例里面的属性
      // 可以在组件中创建一个data()存放属性，data只能是函数类型，而且要返回一个对象
      Vue.component('cpn', {
        template: '#cpn',
        data() {
          return {
            title: 'abc'
          }
        }
      })

      const app = new Vue({
        el: '#app',
        data: {
          message: '你好'
        }
      })
    </script>
  </body>
</html>
